<%@ WebHandler Language="C#" Class="SourceLoader" %>

using System;
using System.Web;
using Manoli.Utils.CSharpFormat;
public class SourceLoader : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        string fileName = context.Request["fileName"];
        System.IO.StreamReader read= new System.IO.StreamReader(context.Server.MapPath(fileName));
        string source= read.ReadToEnd();
        read.Close();
        read.Dispose();
        if (fileName.IndexOf("aspx")!=-1 )
        {
            CSharpFormat format = new CSharpFormat();
            context.Response.Write(format.FormatCode(source));
        }
        else
        {
            HtmlFormat htmformat = new HtmlFormat();
            context.Response.Write(htmformat.FormatCode(source));
        }
       
           
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}